package com.gxa.shop.service.category.impl;

import com.gxa.shop.bean.dto.CategoryQueryPage;
import com.gxa.shop.bean.pojo.Category;
import com.gxa.shop.bean.vo.CategoryOption;
import com.gxa.shop.bean.vo.CategoryVo;
import com.gxa.shop.dao.category.CategoryDao;
import com.gxa.shop.dao.category.impl.CategoryDaoIml;
import com.gxa.shop.service.category.CategoryService;


import java.util.Collections;
import java.util.List;

/**
 * com.gxa.shop.bean.service.impl
 * User: zjy
 * Date: 2024/12/17 14:16
 * motto:   逆水行舟不进则退
 * Description:
 * Version: V1.0
 */
public class CategoryServiceImpl implements CategoryService {
    private CategoryDao categoryDao=new CategoryDaoIml();

    @Override
    public List<CategoryVo> queryById(String categoryId) {
        return categoryDao.queryById(categoryId);
    }

    @Override
    public boolean insert(Category category) {

        return this.categoryDao.insert(category)>0;
    }

    @Override
    public boolean update(Category category) {

        return categoryDao.update(category)>0;
    }

    @Override
    public boolean deleteById(Integer categoryId) {
        return categoryDao.deleteById(categoryId)>0;
    }

    @Override
    public List<Category> findByPage(CategoryQueryPage categoryQueryPage) {
        return categoryDao.findByPage(categoryQueryPage);
    }

    @Override
    public Long findByTotal(CategoryQueryPage categoryQueryPage) {
        if(categoryQueryPage.getCategoryName()==null  ||  categoryQueryPage.getCategoryName().trim().length()==0){
            categoryQueryPage.setCategoryName(null);
        }
        return   categoryDao.findByTotal(categoryQueryPage);
    }

    @Override
    public List<CategoryOption> findAllList() {

        return categoryDao.findAllList();
    }
}